package com.zxy.supplier_system.server.controller

import com.zxy.supplier_system.server.service.ProcurementSupplierStatisticService
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestHeader
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import java.math.BigDecimal
import java.time.YearMonth

@RestController
@RequestMapping("procurementSuppliers/{supplierId}/statistics")
class ProcurementSupplierStatisticController(
    private val procurementSupplierStatisticService:ProcurementSupplierStatisticService
) {

    @GetMapping
    fun procurementSupplierStatistic(){
        return
    }

    data class ProcurementSupplierStatisticResponse(
        val totalFee:BigDecimal,
        val totalPrice:BigDecimal,
        val totalPaidMoney:BigDecimal,
        val totalNeedPaidMoney:BigDecimal,
    )

    data class ProcurementPurchasePriceGroupByYearMonthRequest(
        val startYearMonth:YearMonth?,
        val endYearMonth:YearMonth?,
    )

    @GetMapping("feeDetailGroupByMonth")
    fun procurementPurchasePriceGroupByYearMonth(@PathVariable supplierId: Int,
                                                 @RequestHeader timezone: String,
                                                 request: ProcurementPurchasePriceGroupByYearMonthRequest): ProcurementPurchasePriceGroupByYearMonthResponse{
        return this.procurementSupplierStatisticService.procurementPurchasePriceGroupByYearMonth(supplierId,request,timezone)
    }

    data class ProcurementPurchasePriceGroupByYearMonthResponse(
        val data: List<YearMonthData>
    ){
        data class YearMonthData(
            val statisticYearMonth: YearMonth,
            val procurementFee:BigDecimal?,
            val returnFee:BigDecimal?,
        )
    }

}